/* Global scrolling behavior */
html, body {
  overflow-x: hidden;
}

/* Container */
.plugin-container {
  padding: 1rem;
  width: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 100vh;
  box-sizing: border-box;
  overflow-y: auto;
}

/* Card Base */
.plugin-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-secondary);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: var(--transition-medium);
  box-shadow: var(--shadow-sm);
}

.plugin-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border);
}

/* Header Card */
.header-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border-secondary);
  flex-wrap: wrap;
  gap: 1rem;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.header-icon {
  color: var(--color-accent);
  display: flex;
  align-items: center;
}

.header-content h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
  letter-spacing: -0.025em;
}

.header-content p {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.action-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  font-family: inherit;
}

.action-button:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.action-button.secondary {
  background: var(--color-surface-elevated);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

.action-button.secondary:hover {
  background: var(--color-surface);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.action-button.small {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
}

/* Search Card */
.search-card {
  border-radius: var(--radius-lg);
}

.search-container {
  padding: 1rem 1.5rem;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1rem;
  color: var(--color-text-secondary);
  z-index: 1;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 3rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-elevated);
  color: var(--color-text-primary);
  font-size: 0.875rem;
  transition: var(--transition-fast);
  font-family: inherit;
}

.search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.2);
}

.search-input::placeholder {
  color: var(--color-text-secondary);
}

.clear-button {
  position: absolute;
  right: 0.5rem;
  padding: 0.5rem;
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
}

.clear-button:hover {
  background: var(--color-surface);
  color: var(--color-text-primary);
}

/* Notice Card */
.notice-card {
  border-radius: var(--radius-lg);
  border-color: var(--color-warning);
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.1) 0%, var(--color-surface) 100%);
}

.notice-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
}

.notice-icon {
  color: var(--color-warning);
  flex-shrink: 0;
}

.notice-text {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-primary);
}

/* Loading */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 100;
  border-radius: var(--radius-xl);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top: 3px solid var(--color-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Plugin Grid */
.plugin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  align-items: start;
}

/* Plugin Item Card */
.plugin-item-card {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: var(--transition-medium);
  display: flex;
  flex-direction: column;
  min-height: 200px;
  height: auto;
}

.plugin-item-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.plugin-item-card.disabled {
  opacity: 0.7;
}

/* Plugin Badges */
.cli-badge,
.update-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  z-index: 1;
}

.cli-badge {
  background: var(--color-info);
  color: var(--color-blue-common);
}

.update-badge {
  background: var(--color-success);
  color: white;
  right: 3.5rem;
}

/* Plugin Header */
.plugin-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.plugin-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--color-border-secondary);
}

.plugin-info {
  flex: 1;
  min-width: 0;
}

.plugin-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 0.25rem 0;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.plugin-name:hover {
  color: var(--color-accent);
}

.plugin-version {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--color-text-secondary);
  background: var(--color-surface-elevated);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
}

.plugin-author {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin: 0;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

/* Plugin Description */
.plugin-description {
  margin-bottom: 1.5rem;
  flex: 1;
  display: flex;
  align-items: flex-start;
}

.plugin-description p {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin: 0;
  text-overflow: ellipsis;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 2.6rem;
}

/* Plugin Actions */
.plugin-actions {
  margin-top: auto;
  padding-top: 1rem;
}

.plugin-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  font-family: inherit;
}

.plugin-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.install-button {
  background: var(--color-success);
  color: white;
}

.install-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.installing-button,
.processing-button {
  background: var(--color-surface-elevated);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.installed-button {
  background: var(--color-success-light);
  color: var(--color-success);
  border: 1px solid var(--color-success);
}

.settings-button {
  background: var(--color-accent);
  color: white;
}

.settings-button:hover:not(:disabled) {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
}

.disabled-button {
  background: var(--color-surface-elevated);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.disabled-button:hover:not(:disabled) {
  background: var(--color-surface);
  border-color: var(--color-warning);
  color: var(--color-warning);
}

/* Button Spinner */
.button-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Empty State */
.empty-state {
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
}

.empty-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.empty-icon {
  color: var(--color-text-secondary);
  opacity: 0.5;
}

.empty-content h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
}

.empty-content p {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin: 0;
  max-width: 400px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-container {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 70vw;
  max-height: 80vh;
  width: 100%;
  margin: 2rem;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 1.5rem 0 1.5rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.modal-close:hover {
  background: var(--color-surface-elevated);
  color: var(--color-text-primary);
}

.modal-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-content::-webkit-scrollbar {
  width: 6px;
}

.modal-content::-webkit-scrollbar-track {
  background: var(--color-surface-elevated);
  border-radius: 3px;
}

.modal-content::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-secondary);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.5rem;
  border-top: 1px solid var(--color-border-secondary);
}

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  font-family: inherit;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  background: var(--color-accent);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-accent-hover);
}

.btn-secondary {
  background: var(--color-surface-elevated);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-surface);
  border-color: var(--color-accent);
}

/* Transitions */
.notice-enter-active,
.notice-leave-active {
  transition: all var(--transition-medium);
}

.notice-enter-from,
.notice-leave-to {
  opacity: 0;
  transform: translateY(-1rem);
}

/* Responsive Design */
@media (max-width: 768px) {
  .plugin-container {
    padding: 0.75rem;
    gap: 1rem;
  }

  .header-card .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .plugin-grid {
    grid-template-columns: 1fr;
  }

  .modal-container {
    max-width: 95vw;
    margin: 1rem;
  }

  .action-button {
    min-width: 120px;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .plugin-container {
    padding: 0.5rem;
  }

  .plugin-item-card {
    padding: 1rem;
  }

  .header-actions {
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }

  .action-button {
    width: 100%;
    justify-content: center;
  }
}

/* Dark mode adjustments */
:root.dark .plugin-container,
:root.auto.dark .plugin-container {
  background: var(--color-background-secondary);
}

:root.dark .plugin-card,
:root.auto.dark .plugin-card {
  background: var(--color-surface-elevated);
  border-color: var(--color-border-secondary);
}

:root.dark .search-input,
:root.auto.dark .search-input {
  background: var(--color-surface-elevated);
  border-color: var(--color-border);
  color: var(--color-text-primary);
}

:root.dark .search-input:focus,
:root.auto.dark .search-input:focus {
  border-color: var(--color-accent);
}

:root.dark .modal-container,
:root.auto.dark .modal-container {
  background: var(--color-surface);
  border-color: var(--color-border);
}

:root.dark .btn-secondary,
:root.auto.dark .btn-secondary {
  background: var(--color-surface-elevated);
  border-color: var(--color-border);
}

:root.dark .btn-secondary:hover,
:root.auto.dark .btn-secondary:hover {
  background: var(--color-surface);
  border-color: var(--color-accent);
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for keyboard navigation */
.action-button:focus-visible,
.plugin-button:focus-visible,
.btn:focus-visible,
.search-input:focus-visible,
.clear-button:focus-visible,
.modal-close:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.plugin-name:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
